<template>
	<view>
		<u-card padding="16">
			<view class="" slot="head">
				<view class="wrap">
					<u-row>
						<u-col span="10">
							<view class="title">
								<span>作业内容：</span><span>{{taskInfo.name}}</span>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
			<view class="" slot="body">
				<view class="wrap">
					<u-row>
						<u-col span="6">
							<view class="u-line-1 weikaishi" v-if="taskInfo.status == '未开始'">
								<span>状态：</span><span>{{taskInfo.status}}</span>
							</view>
							<view class="u-line-1 jinxingzhong" v-else-if="taskInfo.status == '作业中'">
								<span>状态：</span><span>{{taskInfo.status}}</span>
							</view>
							<view class="u-line-1 yizuofei" v-else-if="taskInfo.status == '作废'">
								<span>状态：</span><span>{{taskInfo.status}}</span>
							</view>
							<view class="u-line-1 yiwancheng" v-else>
								<span>状态：</span><span>{{taskInfo.status}}</span>
							</view>
						</u-col>
						<u-col span="6" >
							<view class="u-line-1">
								<span>作业日期：</span><span>{{taskInfo.v1}}</span>
							</view>
						</u-col>
						
					</u-row>
					<u-row >
						<u-col span="6">
							<view class="u-line-1 u-m-t-10">
								<span>单号：</span><span>{{taskInfo.orderNumber}}</span>
							</view>
						</u-col>
						<u-col span="6" >
							<view class="u-line-1 u-m-t-10">
								<span>客户单号：</span><span>{{taskInfo.customerNumber}}</span>
							</view>
						</u-col>
						
					</u-row>
					<u-row >
						<u-col span="6" >
							<view class="u-line-1 u-m-t-10">
								<span>类型：</span><span>{{taskInfo.taskWork}}</span>
							</view>
						</u-col>
						<u-col span="6">
							<view class="u-line-1 u-m-t-10">
								<span>类别：</span><span>{{taskInfo.v8}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row >
						<u-col span="6">
							<view class="u-line-1 u-m-t-10">
								<span>车型：</span><span>{{taskInfo.carModel}}</span>
							</view>
						</u-col>
						<u-col span="6">
							<view class="u-line-1 u-m-t-10">
								<span>累计人数：</span><span>{{taskInfo.peoples}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row v-if="taskInfo.taskWork == '跟车'">
						<u-col span="6">
							<view class="u-line-1 u-m-t-10">
								<span>门店数：</span><span>{{taskInfo.v9}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row >
						<u-col span="6">
							<view class="u-line-1 u-m-t-10">
								<span>核算方式：</span><span>{{taskInfo.settlementMode}}</span>
							</view>
						</u-col>
						<u-col span="6" v-if="taskInfo.settlementMode == '体积'">
							<view class="u-line-1 u-m-t-10">
								<span>体积：</span><span>{{taskInfo.volume}}</span>
							</view>
						</u-col>
						<u-col span="6" v-if="taskInfo.settlementMode == '数量'">
							<view class="u-line-1 u-m-t-10">
								<span>数量：</span><span>{{taskInfo.nums}}</span>
							</view>
						</u-col>
						<u-col span="6" v-if="taskInfo.settlementMode == '重量'">
							<view class="u-line-1 u-m-t-10">
								<span>重量(吨)：</span><span>{{taskInfo.weights}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row >
						<u-col span="6">
							<view class="u-line-1 u-m-t-10">
								<span>时效：</span><span>{{taskInfo.prescription}}</span>
							</view>
						</u-col>
						<u-col span="6" >
							<view class="u-line-1 u-m-t-10">
								<span>累计工时：</span><span>{{taskInfo.hours}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row >
						<u-col span="6">
							<view class="u-line-1 u-m-t-10">
								<span>开始时间：</span><span v-if="taskInfo.createTimes">{{taskInfo.createTimes.substring(6, 16)}}</span>
							</view>
						</u-col>
						<u-col span="6">
							<view class="u-line-1 u-m-t-10">
								<span>结束时间：</span><span v-if="taskInfo.endTime">{{taskInfo.endTime.substring(6, 16)}}</span>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
		</u-card>
		<view class="content wrap2">
			<u-form :model="form" ref="uForm"  :rules="rules">
				
				<u-form-item label="纸品总量" label-width="150" prop="nums1"><u-input v-model="form.nums1" placeholder="请输入纸品总量"/></u-form-item>
				<u-form-item label="卫品总量" label-width="150" prop="nums2"><u-input v-model="form.nums2" placeholder="请输入卫品总量"/></u-form-item>
				<u-form-item label="湿巾总量" label-width="150" prop="nums3"><u-input v-model="form.nums3" placeholder="请输入湿巾总量"/></u-form-item>
				
			</u-form>
			<u-button @click="submit">提交</u-button>
		</view>
		<view>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				form:{
				    nums1:"",
				    nums2:"",
				    nums3:"",
				},
				taskId:'',
				taskInfo: {},
			    rules: {
					nums1: [
						{ 
							type:'number',
							message: '请输入正确的数据类型', 
							trigger: 'blur',
						}
					],
					nums2: [
						{
							type:'number',
							message: '请输入正确的数据类型', 
							trigger: 'blur'
						}
					],
					nums3: [
						{
							type:'number',
							message: '请输入正确的数据类型', 
							trigger: 'blur'
						}
					],
				}
			};
		},
		onLoad(open) {
			this.taskId = open.taskid
			this.$http.post('/rest/task/getById',{
			},{
				params: {id:open.taskid},
				header: {
					'Authorization' :uni.getStorageSync('token'),
				}
			}).then(res => {
				this.taskInfo = res.data.data
			})
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		methods:{
			submit() {
				this.$refs.uForm.validate(valid => {
					if (valid) {
						console.log('验证通过');
						uni.showLoading({
							title: '正在提交'
						})
						this.$http.post('/rest/task/chaimingxi?taskId='+this.taskId,{
						},{
							params: this.form,
							header: {
								'Authorization' :uni.getStorageSync('token'),
							}
						}).then(res => {
							uni.hideLoading()
							if(res.data.code == 200) {
								this.$refs.uToast.show({
									title: '操作成功',
									type: 'success'
								})
								setTimeout(() => {
									this.$Router.back()
								}, 1000)
							} else {
								this.$refs.uToast.show({
									title: res.data.message,
									type: 'error'
								})
							}
						})
					} else {
						console.log('验证失败');
					}
				});
			},
		}
	}
</script>
<style lang="scss">
	page{
			background-color: #ffffff;
	}
	
	.wrap {
		padding: 5rpx;
	}
	.wrap2 {
		padding: 30rpx;
	}
</style>
